package com.hecore.lagou.speak;

import com.hecore.lagou.speak.component.SpeakMapper;
import com.hecore.lagou.speak.component.SpeakReducer;
import com.hecore.lagou.speak.entity.SpeakBean;
import com.hecore.lagou.speak.entity.SpeakBeanSort;
import com.hecore.lagou.speak.soft.SortMapper;
import com.hecore.lagou.speak.soft.SortReducer;
import com.hecore.lagou.util.CommonSettingUtil;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;

/**
 * @Author: hecore
 * @Date: 2020/10/19 00:21
 * @Description:
 * 对于全局排序需要保证只有⼀个reduceTask
 */

public class SortDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        final Configuration config=new Configuration();
        Job job=Job.getInstance(config,"soft-dirver");
        setJobConfig(job);
        // param
        // 1.3 in&out set
        CommonSettingUtil.setOut(job,args);

    }

    private static void setJobConfig(Job job) {
        // jar set
        job.setJarByClass(SortDriver.class);
        // mapper&reducer set
        job.setMapperClass(SortMapper.class);
        job.setReducerClass(SortReducer.class);
        //map out set
        job.setMapOutputKeyClass(SpeakBeanSort.class);
        job.setMapOutputValueClass(NullWritable.class);
        // final out set
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(SpeakBeanSort.class);

    }

}
